function Next (eventMask: integer): Boolean; { returns True if an event of the type requested was found. }
function Available (eventMask: integer): Boolean; { returns True if an event of the type requested is available. }
procedure Loop;
end;
As shown in example 5, DoMouseDown first determines where the event occurred (by calling FindWindow). If the event occurred on the desktop, DoMouseDown does nothing. If the event occurred in a menu, it sends
-- part contents for card part 2
----- text -----
a message to the global menu bar object
(theMenuBar) to dispatch a message to the appropriate object depending on the menu item that was chosen. If the mouse down event occurred in a system window, the system is allowed to handle it by a call to the Toolbox routine, SystemClick. If the event did not take place in any of the above locations, it assumes that the event was in a window and the appropriate message is sent to TWindow.
Notice that the object reference is retrieved from the window record's refcon field. However, the refcon is defined as a LongInt and hence casting to the TWindow type is necessary for the compiler to accept the statement.